<template>
  <el-form
    ref="userForm"
    :model="userInfo"
    label-width="120px"
    style="margin-left: 120px; margin-top: 30px"
  >
    <el-form-item label="姓名:" prop="username">
      <el-input v-model="userInfo.username" style="width:300px" />
    </el-form-item>
    <el-form-item label="密码:" prop="password">
      <el-input v-model="userInfo.password" type="password" style="width:300px" />
    </el-form-item>

    <el-form-item>
      <el-button type="primary" @click="doUpdate">更新</el-button>
    </el-form-item>
  </el-form>
</template>
<script>
import { getUserDetail, getUpdateEmployee } from '@/api/employee'
export default {
  data() {
    return {
      userInfo: {
        username: '',
        password: ''
      }

    }
  },
  created() {
    this.loadUserDetail()
  },
  methods: {
    async loadUserDetail() {
      const id = this.$route.query.id
      const { data: res } = await getUserDetail(id)
      // console.log(res)
      this.userInfo = { ...res.data }
    },
    async doUpdate() {
      const { data: res } = await getUpdateEmployee(this.userInfo)
      // console.log('更新员工信息', res)
      this.$message.success(res.message)
    }
  }
}
</script>

